package com.longxi.tianjintianbao.ui.activity.repair;

import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioGroup;
import android.widget.TextView;

import com.longxi.tianjintianbao.R;
import com.longxi.tianjintianbao.ui.base.BaseActivity;
import com.longxi.tianjintianbao.ui.presenter.repair.UpdateRepairContentAtPresenter;
import com.longxi.tianjintianbao.ui.view.repair.IUpdateRepairContentAtView;

import butterknife.BindView;

public class UpdateRepairContentActivity extends BaseActivity<IUpdateRepairContentAtView, UpdateRepairContentAtPresenter> implements IUpdateRepairContentAtView {
    @BindView(R.id.tvSelectArea)
    TextView mTvSelectArea;
    @BindView(R.id.etAddress)
    EditText mEtAddress;
    @BindView(R.id.tvRepairArea)
    TextView mTvRepairArea;
    @BindView(R.id.rgCustomType)
    RadioGroup mRgCustomType;
    @BindView(R.id.etContent)
    EditText mEtContent;
    @BindView(R.id.recyclerView)
    RecyclerView mRecyclerView;
    @BindView(R.id.tvRequireDate)
    TextView mTvRequireDate;
    @BindView(R.id.btnLogin)
    Button mBtnLogin;

    @Override
    protected int provideContentViewId() {
        return R.layout.activity_update_repair_content;
    }

    @Override
    public void initData() {
        super.initData();
        mPresenter.setBar();
        mPresenter.initPicture();
    }

    @Override
    public void initListener() {
        super.initListener();
        mBtnLogin.setOnClickListener(v -> mPresenter.updateEventRepair());
        mTvRequireDate.setOnClickListener(v -> mPresenter.getCurrentDateTimeNoSS(mTvRequireDate, true));
        mTvRepairArea.setOnClickListener(v -> mPresenter.showSelectRepairArea());

        mRgCustomType.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if(checkedId == R.id.rBtnYG){
                    mPresenter.custtype = mPresenter.CUSTTYPE_YG;
                }else{
                    mPresenter.custtype = mPresenter.CUSTTYPE_ZH;
                }
            }
        });
    }

    @Override
    protected UpdateRepairContentAtPresenter createPresenter() {
        return new UpdateRepairContentAtPresenter(this);
    }

    @Override
    public TextView getTvSelectArea() {
        return mTvSelectArea;
    }

    @Override
    public EditText getEtAddress() {
        return mEtAddress;
    }

    @Override
    public TextView getTvRepairArea() {
        return mTvRepairArea;
    }

    @Override
    public RadioGroup getRgCustomType() {
        return mRgCustomType;
    }

    @Override
    public EditText getEtContent() {
        return mEtContent;
    }

    @Override
    public RecyclerView getRecyclerView() {
        return mRecyclerView;
    }

    @Override
    public TextView getTvRequireDate() {
        return mTvRequireDate;
    }

    @Override
    public Button getBtnLogin() {
        return mBtnLogin;
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if(resultCode != RESULT_OK){
            return;
        }
        mPresenter.onActivityResult(requestCode, data);
    }

}


